#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>
#include <queue>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
struct ListNode {
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

class Solution {
public:
    vector<ListNode*> listOfDepth(TreeNode* tree) {
        queue<TreeNode*> q;
        vector<ListNode*> ans;
        if(tree==nullptr) return ans;
        q.push(tree);
        q.push(nullptr);
        ListNode *lt=nullptr,*head=nullptr;
        int flag=1;
        while(!q.empty()){
            TreeNode* node=q.front();q.pop();
            if(node==nullptr){
                if(head!=nullptr)
                    ans.push_back(head);
                head=lt=nullptr;
                if(flag){
                    q.push(nullptr);
                    flag=0;
                }
            }else{
                flag=1;
                if(lt==nullptr){
                    lt=new ListNode(node->val);
                    head=lt;
                }else{
                    lt->next=new ListNode(node->val);
                    lt=lt->next;
                }
                if(node->left!=nullptr) q.push(node->left);
                if(node->right!=nullptr) q.push(node-> right);
            }
        }
        return ans;
    }
};

int main(){




    return 0;
}